// 将数据转换为树形结构
export const buildLeaderTree = (items: any[], pid: number | null = null): any[] => {
    return items
        .filter(items => items.pid === pid)
        .map(item => ({
            ...item,
            key: item.id.toString(),
            title: item.name,
            children: buildLeaderTree(items, item.id)
        }))
}

// 获取部门列表数据并构建树形结构
export const getLeadertreeData = (data: any[], pid: number | null = 0): any[] => {
    return buildLeaderTree(data, pid)
}

// 将数据转换为树形结构
export const buildLeaderTree1 = (items: any[], pid: number | null = null): any[] => {
    return items
        .filter(item => item.pid === pid)
        .map(item => ({
            value: item.id,
            label: item.name,
            disabled: item.status === 'disabled', // 根据条件禁用节点
            children: buildLeaderTree1(items, item.id)
        }));
}

// 获取部门列表数据并构建树形结构
export const getLeadertreeData1 = (data: any[], pid: number | null = 0): any[] => {
    return buildLeaderTree1(data, pid)
}

